home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Developer University / DUProjects / Data / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-03-29  |  3.2 KB  |  126 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 1 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //=======================================================================
  5. #ifndef PART_H
  6. #include "Part.h"
  7. #endif
  8.  
  9. #ifndef CONTENT_H
  10. #include "Content.h"
  11. #endif
  12.  
  13. #ifndef FRAME_H
  14. #include "Frame.h"
  15. #endif
  16.  
  17. // ----- Framework Layer -----
  18. #ifndef FWCONTXT_H
  19. #include "FWContxt.h"            // FW_CViewContext
  20. #endif
  21.  
  22. #ifndef FWEVENTU_H
  23. #include "FWEventU.h"            // FW_IsCommandKeyPressed
  24. #endif
  25.  
  26. // ----- OS Layer -----
  27. #ifndef FWCFMRES_H
  28. #include "FWCFMRes.h"            // FW_CSharedLibraryResourceFile, FW_gInstance
  29. #endif
  30.  
  31. #ifndef FWMENU_H
  32. #include "FWMenu.h"                // FW_CMenuBar, etc.
  33. #endif
  34.  
  35. #ifndef FWEVENT_H
  36. #include "FWEvent.h"            // FW_CMenuEvent, FW_CMouseEvent
  37. #endif
  38.  
  39. #ifndef FWRECSHP_H
  40. #include "FWRecShp.h"            // FW_CRectShape
  41. #endif
  42.  
  43. #ifndef FWPICSHP_H
  44. #include "FWPicShp.h"            // FW_PPicture, FW_CPictureShape
  45. #endif
  46.  
  47. #ifndef FWRRCSHP_H
  48. #include "FWRRcShp.h"            // FW_CRoundRectShape
  49. #endif
  50.  
  51. #ifndef FWCMD_H
  52. #include "FWCmd.h"                // FW_CCommand
  53. #endif
  54.  
  55. // ----- OpenDoc Includes -----
  56. #ifndef SOM_ODDragItemIterator_xh
  57. #include <DgItmIt.xh>            // ODDragItemIterator
  58. #endif
  59.  
  60. #ifndef SOM_ODTranslation_xh    
  61. #include <Translt.xh>            // ODTranslation    
  62. #endif
  63.  
  64. #ifndef SOM_ODSession_xh
  65. #include <ODSessn.xh>            // ODSession
  66. #endif
  67.  
  68. #ifndef SOM_Module_OpenDoc_StdProps_defined
  69. #include <StdProps.xh>            // kODPropContents
  70. #endif
  71.  
  72. //========================================================================================
  73. #ifdef FW_BUILD_MAC
  74. #pragma segment Data
  75. #endif
  76.  
  77. FW_DEFINE_AUTO(CDataFrame)
  78.  
  79. //========================================================================================
  80. CDataFrame::CDataFrame(Environment* ev, ODFrame* odFrame, 
  81.                                     FW_CPresentation* presentation, CDataContent* content)
  82.   : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
  83.     fDataContent(content)
  84. {
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. CDataFrame::~CDataFrame()
  89. {
  90. }
  91.  
  92. //----------------------------------------------------------------------------------------
  93. void 
  94. CDataFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  95. {
  96.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  97.     FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
  98.     FW_CRect frameRect = this->GetBounds(ev);
  99.     FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
  100.     
  101.     // draw pizzas
  102.     CPizzaCollection* list = fDataContent->MyGetPizzaList();
  103.     CPizzaCollectionIterator iter(list);
  104.     CPizza* pizza = NULL;
  105.     for (pizza = (CPizza*) iter.First(); iter.IsNotComplete(); pizza = (CPizza*) iter.Next())
  106.         {
  107.         if (::FW_IsCommandKeyPressed()) 
  108.                 pizza->Draw(context);
  109.         else
  110.             if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
  111.                 pizza->Draw(context);
  112.         }
  113. }
  114.  
  115. //----------------------------------------------------------------------------------------
  116. FW_Boolean 
  117. CDataFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  118. {    
  119.     FW_UNUSED(ev);
  120.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  121.     this->GetContentView(ev)->FrameToViewContent(ev, where);    
  122.     fDataContent->MyIncrement(ev, where);
  123.     return true;
  124. }
  125.  
  126.